package com.yihuier.yihuier.Service.UserManager;

import com.yihuier.yihuier.Entity.UserManager.Department;
import com.yihuier.yihuier.Mapper.UserManager.DepartmentMapper;
import com.yihuier.yihuier.Mapper.UserManager.DepartmentUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service
public class DepartmentService {
    /**
     * 数据库映射
     */
    @Autowired
    private DepartmentMapper departmentMapper;


    /**
     * 根据部门编号获取公司编号
     * @param department_id 部门编号
     * @return 公司编号
     */
    public int getCompanyIdByDepartmentId(int department_id){return departmentMapper.selectCompanyIdByDepartmentId(department_id);}

    /**
     * 根据公司编号获取部门编号和部门名称
     * @param company_id 公司编号
     * @return 部门编号和部门名称
     */
    public ArrayList<Department> getDepartmentIdsAndDepartmentNames(int company_id){return departmentMapper.selectDepartmentIdsAndDepartmentNamesByCompanyId(company_id);}

    /**
     * 添加部门
     * */
    public int addDepartment(String department_name,int company_id ){
        return departmentMapper.insertDepartment(department_name,company_id);
    }

    public String getDepartmentNameById(int department_id){
        return departmentMapper.selectNameById(department_id);
    }

}
